package com.tutorialspoint;

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;

public class MainApp {
   public static void main(String[] args) {
	   ConfigurableApplicationContext context = 
             new ClassPathXmlApplicationContext("Beans.xml");

	  context.start();
	   
      HelloWorld objA = (HelloWorld) context.getBean("helloWorld");
    //  objA.setMessage("I' m object A");
      objA.getMessage1();
      objA.getMessage2();
      
      context.start();
      
      HelloIndia objHI = (HelloIndia) context.getBean("helloIndia");
      objHI.getMessage1();
      objHI.getMessage2();
      objHI.getMessage3();
      
//      HelloWorld objB = (HelloWorld)context.getBean("helloWorld");
//      objB.getMessage1(); 
      
      HelloSun objHS = (HelloSun)context.getBean("helloSun");
      objHS.getMessage();
      
      context.registerShutdownHook();
      
      context.stop();
   }
}